﻿//********************************************************************************//
//创建日期：<创建日期，2016-05-23>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：自来水公司数据查询
//********************************************************************************//
using BLL;
using BLL.Access;
using DevExpress.Web;
using Entity;
using System;
using System.Data;
using System.Web.UI;
using Web.Class;

namespace Web.Pages.YongShui._12.ChaXunGL
{
    public partial class ZiLaiShuiGSSJCX : BasePage
    {
        #region 属性

        /// <summary>
        /// 保存结果集1
        /// </summary>
        private DataTable dtYueChaoBQKTab1
        {
            get
            {
                return ViewState["dtYueChaoBQKTab1"] as DataTable;
            }
            set
            {
                ViewState["dtYueChaoBQKTab1"] = value;
            }
        }

        /// <summary>
        /// 保存结果集2
        /// </summary>
        private DataTable dtJinYiNSJTab2
        {
            get
            {
                return ViewState["dtJinYiNSJTab2"] as DataTable;
            }
            set
            {
                ViewState["dtJinYiNSJTab2"] = value;
            }
        }

        /// <summary>
        /// 保存结果集3
        /// </summary>
        private DataTable dtShiKaoHSLFXtab3
        {
            get
            {
                return ViewState["dtShiKaoHSLFXtab3"] as DataTable;
            }
            set
            {
                ViewState["dtShiKaoHSLFXtab3"] = value;
            }
        }

        /// <summary>
        /// 保存结果集4_1
        /// </summary>
        private DataTable dtShiKaoHSLFXtab4_1
        {
            get
            {
                return ViewState["dtShiKaoHSLFXtab4_1"] as DataTable;
            }
            set
            {
                ViewState["dtShiKaoHSLFXtab4_1"] = value;
            }
        }
        /// <summary>
        /// 保存结果集4_2
        /// </summary>
        private DataTable dtShiKaoHSLFXtab4_2
        {
            get
            {
                return ViewState["dtShiKaoHSLFXtab4_2"] as DataTable;
            }
            set
            {
                ViewState["dtShiKaoHSLFXtab4_2"] = value;
            }
        }

        /// <summary>
        /// 保存结果集5_1
        /// </summary>
        private DataTable dtJiHuaYSLtab5_1
        {
            get
            {
                return ViewState["dtJiHuaYSLtab5_1"] as DataTable;
            }
            set
            {
                ViewState["dtJiHuaYSLtab5_1"] = value;
            }
        }
        /// <summary>
        /// 保存结果集5_2
        /// </summary>
        private DataTable dtJiHuaYSLtab5_2
        {
            get
            {
                return ViewState["dtJiHuaYSLtab5_2"] as DataTable;
            }
            set
            {
                ViewState["dtJiHuaYSLtab5_2"] = value;
            }
        }
        /// <summary>
        /// 保存结果集tab6
        /// </summary>
        private DataTable dtKaoHeSLtab6
        {
            get
            {
                return ViewState["dtKaoHeSLtab6"] as DataTable;
            }
            set
            {
                ViewState["dtKaoHeSLtab6"] = value;
            }
        }

        /// <summary>
        /// 当前操作项ID tab1
        /// </summary>
        private string ShuiBiaoHTab1_ID
        {
            get
            {
                return ViewState["ShuiBiaoHTab1_ID"] as string;
            }
            set
            {
                ViewState["ShuiBiaoHTab1_ID"] = value;
            }
        }
        /// <summary>
        /// 当前操作项ID
        /// </summary>
        private int KaoHeSLTab6_ID
        {
            get
            {
                return Convert.ToInt32(ViewState["KaoHeSLTab6_ID"]);
            }
            set
            {
                ViewState["KaoHeSLTab6_ID"] = value;
            }
        }

        /// <summary>
        /// 最小水量年
        /// </summary>
        private int min_ym 
        {
            get
            {
                return Convert.ToInt32( ViewState["min_ym"]);
            }
            set
            {
                ViewState["min_ym"] = value;
            }
        }

        /// <summary>
        /// 最大水量年
        /// </summary>
        private int max_ym
        {
            get
            {
                return Convert.ToInt32(ViewState["max_ym"] );
            }
            set
            {
                ViewState["max_ym"] = value;
            }
        }
        #endregion

        #region 变量

        /// <summary>
        /// 行政区bll
        /// </summary>
        YS_JX_XINGZHENGQBLL _YS_JX_XINGZHENGQBLL = new YS_JX_XINGZHENGQBLL();
        /// <summary>
        /// 配置表bll
        /// </summary>
        S_WORDSBLL _S_WORDSBLL = new S_WORDSBLL();

        /// <summary>
        /// 考核水量
        /// </summary>
        YS_CX_KAOHESL _YS_CX_KAOHESL = new YS_CX_KAOHESL();

        /// <summary>
        /// 考核水量BLL
        /// </summary>
        YS_CX_KAOHESLBLL _YS_CX_KAOHESLBLL = new YS_CX_KAOHESLBLL();
        /// <summary>
        /// 存储过程调用类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();
        /// <summary>
        /// 数据访问操作类
        /// </summary>
        BLL.SqlHelper _splHelper = new BLL.SqlHelper();

        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                InitData();
            }
            if (ASPxPageControl1.ActiveTabIndex==0) 
            {
                gvYueChaoBQKTab1.DataSource = this.dtYueChaoBQKTab1;
                gvYueChaoBQKTab1.DataBind();
            }
        }


        /// <summary>
        /// 查询信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnChaXunTab1_Click(object sender, EventArgs e)
        {
            LoadGridDataTab1();
            if (this.dtYueChaoBQKTab1 == null || this.dtYueChaoBQKTab1.Rows.Count < 1)
            {
                txtShuiBiaoH.Text = "";
                txtXingZhengQK.Text = "";
                txtSheShuiDXDM.Text = "";
                txtSheShuiDXMC.Text = "";
                txtChaoBiaoRQ.Text = "";
                txtBiaoFenL.Text = "";
                txtShuiBiaoHM2.Text = "";
                txtChaoMa.Text = "";
                txtYongShuiL.Text = "";
                txtShuiBiaoDZ2.Text = "";
                txtChaoBiaoZT.Text = "";
                txtShuiSiZT.Text = "";
                txtKouJing.Text = "";
                txtZongBiaoH.Text = "";
                txtGuanWangKH2.Text = "";
                txtBiaoCeH.Text = "";
                txtZhuangBiaoRQ.Text = "";
                txtYongShuiJ.Text = "";
            }
        }

        protected void btnChaXunTab2_Click(object sender, EventArgs e)
        {
            //int hid = 1;
            //hidValue.Value = hid.ToString();
            LoadGridDataTab2(1);
        }

        protected void btnChaXunTab3_Click(object sender, EventArgs e)
        {
            LoadGridDataTab3();
        }

        protected void btnChaXunTab4_Click(object sender, EventArgs e)
        {
            LoadGridDataTab4();
        }
        protected void btnChaXunTab5_Click(object sender, EventArgs e)
        {
            LoadGridDataTab5();
        }

       

        /// <summary>
        /// 表格点击行事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvYueChaoBQKTab1_FocusedRowChanged(object sender, EventArgs e)
        {
            //if (this.dtYueChaoBQKTab1 != null && this.dtYueChaoBQKTab1.Rows.Count > 0)
            //{
            //    this.ShuiBiaoHTab1_ID = this.gvYueChaoBQKTab1.GetRowValues(this.gvYueChaoBQKTab1.FocusedRowIndex, "S_SHUIBIAOBH").ToString();
            //    SetDataTab1();
            //}
        }

        
        /// <summary>
        /// tab3导出excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExportExceltab3_Click(object sender, EventArgs e)
        {
            if (this.dtShiKaoHSLFXtab3 != null && this.dtShiKaoHSLFXtab3.Rows.Count > 0)
            {
                PageTools.ExportExcel(this.dtShiKaoHSLFXtab3);
            }
        }
        #endregion

        #region 方法

        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            gvYueChaoBQKTab1.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            // 加载抄表部门
            LoadCBBM();
            // 加载行政区
            LoadXingZhengQ();
            //水量年月
            LoadShuiLiangYM();
            //涉水对象
            LoadYSXZ_SSDX();
            //抄表状态，水司状态
            LoadWords();
            //根据当前登陆人判断考核类型的加载
            cbmKaoHeLX.Items.Clear();
            cbmKaoHeLX.Items.Add("全部", "0");
            cbmKaoHeLX.Items.Add("应考核", "1");
            cbmKaoHeLX.Items.Add("实考核", "2");
            cbmKaoHeLX.Items.Add("未考核", "3");

            //根据操作人加载管理部门(站点)
            int userid = LoginInfo.CurrentUser.UserID;
            DataTable dtZhanDian = BusinessTool.GetTextAndValue("View_AS_UserInfo", "ZHANDIANBH", "ROLEID", null, string.Format("USERID={0}", userid)).Tables[0];
            //string zhandian = dtZhanDian.Rows[0]["TEXT"].ToString();//站点
            string roleid = dtZhanDian.Rows[0]["VALUE"].ToString();//9001 业务员，3001 办事处主任
            if (roleid == "2003" || roleid == "99999" || roleid == "1001" || roleid == "1002" || roleid == "2001" || roleid == "4002" || userid == 45)
            {
                cbmKaoHeLX.Items.Add("预考核", "4");
                cbmKaoHeLX.Items.Add("已考核", "5");
                cbmKaoHeLX.Items.Add("非已考核", "6");
            }
            cbmKaoHeLX.Items.Add("不考核", "7");
            cbmKaoHeLX.SelectedIndex = 0;
            //获取考核水量的最大水量年月和最小水量年月
            DataTable dt_mym = _SpHelper.P_YSCX_ZLSGSSJCX_KHSL_YM().Tables[0];
            this.min_ym = Convert.ToInt32(dt_mym.Rows[0]["MINYM"]);
            this.max_ym = Convert.ToInt32(dt_mym.Rows[0]["MAXYM"]);
            LoadDataTab6();
        }
        /// <summary>
        /// 加载抄表部门
        /// </summary>
        private void LoadCBBM() 
        {
            //string[] arrCBBM = new string[19] { "市南", "市北", "浦东", "闵行", "虹口", "杨浦", "新黄浦", "卢湾", "长宁", "徐汇", "闸北", "普陀", "普北", "普南", "静安", "黄埔", "宝山", "青浦", "松江" };
            string[] arrCBBM = new string[4] { "城投", "浦东", "川沙", "崇明" };
            for (int i = 0; i < arrCBBM.Length;i++ ) 
            {
                cmbChaoBiaoBMtab1.Items.Add(arrCBBM[i], i + 2);
                //cmbChaoBiaoBMtab2.Items.Add(arrCBBM[i], i + 2);
                cmbChaoBiaoBMtab3.Items.Add(arrCBBM[i], i + 2);
            }
        }
        
        /// <summary>
        /// 加载行政区
        /// </summary>
        private void LoadXingZhengQ()
        {
            DataTable dtXingZhengQ = _YS_JX_XINGZHENGQBLL.SelectYS_JX_XINGZHENGQsDynamic("i_jlzt=0", " s_bianhao");
            for (int i = 0; i < dtXingZhengQ.Rows.Count; i++)
            {
                cmbXingZhengQtab1.Items.Add(dtXingZhengQ.Rows[i]["s_bianhao"] + "_" + dtXingZhengQ.Rows[i]["S_MINGCHENG"].ToString(), dtXingZhengQ.Rows[i]["s_bianhao"]);
                cmbXingZhengQtab3.Items.Add(dtXingZhengQ.Rows[i]["s_bianhao"] + "_" + dtXingZhengQ.Rows[i]["S_MINGCHENG"].ToString(), dtXingZhengQ.Rows[i]["s_bianhao"]);

                cmbChaoBiaoBMtab2.Items.Add(dtXingZhengQ.Rows[i]["s_bianhao"] + "_" + dtXingZhengQ.Rows[i]["S_MINGCHENG"].ToString(), dtXingZhengQ.Rows[i]["s_bianhao"]);
            }
            cmbChaoBiaoBMtab2.SelectedIndex = 1;

            if (cmbXingZhengQtab1.Items.Count > 1) cmbXingZhengQtab1.SelectedIndex = 1;
        }
        /// <summary>
        /// 加载水量年月
        /// </summary>
        private void LoadShuiLiangYM() 
        {
            string water_y_m = BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.WATER_Y_M.ToString());
            int? maxym = 0;
            _SpHelper.P_YSCX_ZLSGSSJCX_MAXYM(out maxym);
            txtShuiLiangYMtab6.Text = maxym.ToString();
            int i_y = Convert.ToInt32(water_y_m) / 100;
            int i_m = Convert.ToInt32(water_y_m) % 100;
            for (int i = i_y - 5; i <= i_y+5; i++)
            {
                cmbShuiLiangYtab1.Items.Add(i.ToString());
                cmbShuiLiangYtab2.Items.Add(i.ToString());
                cmbShuiLiangYtab3.Items.Add(i.ToString());
                cmbShuiLiangYtab4.Items.Add(i.ToString());
                cmbShuiLiangYtab5.Items.Add(i.ToString());
            }
            cmbShuiLiangYtab1.SelectedIndex = 5;
            cmbShuiLiangYtab2.SelectedIndex = 5;
            cmbShuiLiangYtab3.SelectedIndex = 5;
            cmbShuiLiangYtab4.SelectedIndex = 5;
            cmbShuiLiangYtab5.SelectedIndex = 5;
            for (int i = 1; i <= 12; i++) 
            {
                cmbShuiLiangMtab1.Items.Add(i.ToString());
                cmbShuiLiangMtab2.Items.Add(i.ToString());
                cmbShuiLiangMtab3.Items.Add(i.ToString());
                cmbShuiLiangMtab4.Items.Add(i.ToString());
                cmbShuiLiangMtab5.Items.Add(i.ToString());
            }
            cmbShuiLiangMtab1.SelectedIndex = i_m - 1;
            cmbShuiLiangMtab2.SelectedIndex = i_m - 1;
            cmbShuiLiangMtab3.SelectedIndex = i_m - 1;
            cmbShuiLiangMtab4.SelectedIndex = i_m - 1;
            cmbShuiLiangMtab5.SelectedIndex = i_m - 1;
        }

        /// <summary>
        /// 加载涉水对象
        /// </summary>
        private void LoadYSXZ_SSDX()
        {
            //涉水对象
            //涉水对象
            var dt_ssdx = _SpHelper.P_YSCX_YSXZ_SSDX(2).Tables[0];
            for (var i = 0; i < dt_ssdx.Rows.Count; i++)
            {
                cmbSheShuiDXFL_h1.Items.Add(dt_ssdx.Rows[i]["XH"] + "_" + dt_ssdx.Rows[i]["NA"], dt_ssdx.Rows[i]["XH"]);
            }
            //行业分类
            var dt_hhfl = _SpHelper.P_YSCX_YSXZ_SSDX(3).Tables[0];
            for (var i = 0; i < dt_hhfl.Rows.Count; i++)
            {
                cmbSheShuiDXFL_h2.Items.Add(dt_hhfl.Rows[i]["XH"] + "_" + dt_hhfl.Rows[i]["NA"], dt_hhfl.Rows[i]["XH"]);
            }
        }

        /// <summary>
        /// 加载抄表状态，水司状态
        /// </summary>
        private void LoadWords()
        {
            DataTable dtShuiBiao = _S_WORDSBLL.SelectS_WORDsDynamic("belongid IN (6,9) ", "BELONGID,wordsid");
            for (int i = 0; i < dtShuiBiao.Rows.Count; i++)
            {
                if (Convert.ToInt32(dtShuiBiao.Rows[i]["BELONGID"]) == 9)
                {
                    cbmChaoBiaoZT.Items.Add(dtShuiBiao.Rows[i]["WORDSID"] + "_" + dtShuiBiao.Rows[i]["WORDSCONTENT"].ToString(), dtShuiBiao.Rows[i]["WORDSID"]);
                }
            }
            //string[] arrSSZT = new string[] { "G1停走", "G2失灵", "G3黑面", "G4壳漏", "G5玻璃", "G6倒装", "G7针偏", "G8其他", "H1推算估计", "H2新表实发", "H3推算正常", "H4实发估计", "J0空屋", "J1新装", "J2多估", "J3未拆" };
            //for (int i = 0; i < arrSSZT.Length; i++) 
            //{
            //    cbmShuiSiZT.Items.Add(arrSSZT[i]);
            //}
        }
       

        /// <summary>
        /// 加载查询数据
        /// </summary>
        private void LoadGridDataTab1()
        {
            // 自来水数据转码（临时用）
            //_splHelper.TranCodeZlsgssj();

            string sCbbm = cmbChaoBiaoBMtab1.Text;
            string sXzq = cmbXingZhengQtab1.Value.ToString();
            string sUoID = cmbSuoID.Value.ToString();
            int i_y = Convert.ToInt32(cmbShuiLiangYtab1.Text);
            int i_m = Convert.ToInt32(cmbShuiLiangMtab1.Text);
            string sKhlx = cbmKaoHeLX.Text;
            int v_b = -1;
            string constr = "";
            string sYsl = "";
            #region 查询条件
            if (rbnShuiBiaoBH.Checked && txtShuiBiaoBH.Text!="")//水表编号
            {
                v_b = 1;
                constr = txtShuiBiaoBH.Text;
            }
            else if (rbnYongHuH.Checked && txtYongHuH.Text!="")//用户号
            {
                v_b = 2;
                constr = txtYongHuH.Text;
            }
            else if (rbnShuiBiaoHM.Checked && txtShuiBiaoHM.Text!="")//水表户名
            {
                v_b = 3;
                constr = txtShuiBiaoHM.Text;
            }
            else if (rbnShuiBiaoDZ.Checked && txtShuiBiaoDZ.Text!="") //水表地址
            {
                v_b = 4;
                constr = txtShuiBiaoDZ.Text;
            }
            else if (rbnSheShuiDXFL.Checked)//涉水对象分类
            {
                if (cmbSheShuiDXFL_q1.Text != "" && cmbSheShuiDXFL_h1.Text != "")
                {
                    v_b = 5;
                    constr = cmbSheShuiDXFL_q1.Text + cmbSheShuiDXFL_h1.Value.ToString();
                    if (cmbSheShuiDXFL_q2.Text != "" && cmbSheShuiDXFL_h2.Text != "")
                    {
                        constr += " AND  Z.S_DAIMA ";
                        constr += cmbSheShuiDXFL_q2.Text + cmbSheShuiDXFL_h2.Value.ToString();
                    }
                }
            }
            else if (rbnChaoBiaoZT.Checked && cbmChaoBiaoZT.Text!="")//抄表状态
            {
                v_b = 6;
                constr = cbmChaoBiaoZT.Value.ToString();
            }
            else if (rbnShuiSiZT.Checked && txtShuiSiZT1.Text!="")//水司状态
            {
                v_b = 7;
                constr = txtShuiSiZT1.Text;
            }
            else if (rbnGuanWangKH.Checked && txtGuanWangKH.Text!="")//管网块号
            {
                v_b = 8;
                constr = txtGuanWangKH.Text;
            }
            else if (rbnCeHao.Checked && txtCeHao.Text!="")//册号
            {
                v_b = 9;
                constr = txtCeHao.Text;
            }
            else if (rbnDanJia.Checked && cbmDanJia.Text!=""&& txtDanJia.Text!="")//用水价
            {
                v_b = 10;
                constr = cbmDanJia.Text + txtDanJia.Text;
            }
            else if (rbnZhanghuBH.Checked && txtZhanghuBH.Text != "")//账户编号
            {
                v_b = 12;
                constr = txtZhanghuBH.Text;
            }
            else if (rbnFuWuDianBS.Checked && txtFuWuDianBS.Text != "")//服务点标识
            {
                v_b = 13;
                constr = txtFuWuDianBS.Text;
            }
            //else if (rbnXuNiB.Checked)//虚拟表
            //{
            //    v_b = 11;
            //    constr = "";
            //}
            #endregion
            if (cbmShuiLiangFW1.Text != "" && txtShuiLiangFW1.Text!="") 
            {
                sYsl =" AND A.I_YONGSHUIL"+ cbmShuiLiangFW1.Text + txtShuiLiangFW1.Text;
            }
            if (cbmShuiLiangFW2.Text != "" && txtShuiLiangFW2.Text != "")
            {
                sYsl += " AND A.I_YONGSHUIL" + cbmShuiLiangFW2.Text + txtShuiLiangFW2.Text;
            }
            this.dtYueChaoBQKTab1 = _SpHelper.P_YSCX_ZLSGSSJCX_YCBCX(sCbbm, sXzq,sUoID, i_y, i_m, sKhlx, v_b, constr, sYsl).Tables[0];
            gvYueChaoBQKTab1.DataSource = this.dtYueChaoBQKTab1;
            gvYueChaoBQKTab1.DataBind();
            int zsl = 0;
            for (int i = 0; i < this.dtYueChaoBQKTab1.Rows.Count;i++ )
            {
                 zsl+= Convert.ToInt32(this.dtYueChaoBQKTab1.Rows[i]["I_YONGSHUIL"]);
            }
            txtZongShuiL.Text = zsl.ToString();
            txtShuiBiaoZS.Text = this.dtYueChaoBQKTab1.Rows.Count.ToString();
           if (this.dtYueChaoBQKTab1 != null && this.dtYueChaoBQKTab1.Rows.Count > 0) 
           {
               gvYueChaoBQKTab1.FocusedRowIndex = -1;
               gvYueChaoBQKTab1.FocusedRowIndex = 0;
               //SetDataTab1();
           }           
        }

        /// <summary>
        /// 给显示框赋值
        /// </summary>
        //private void SetDataTab1()
        //{
        //    DataTable dt_temp = _SpHelper.P_YSCX_ZLSGSSJCX_YCBCX("全部", "全部", Convert.ToInt32(cmbShuiLiangYtab1.Text), Convert.ToInt32(cmbShuiLiangMtab1.Text), "全部", 1, ShuiBiaoHTab1_ID, "").Tables[0];
        //    if (dt_temp != null && dt_temp.Rows.Count > 0)
        //    {
        //        txtShuiBiaoH.Text = dt_temp.Rows[0]["S_SHUIBIAOBH"].ToString();
        //        txtXingZhengQK.Text = dt_temp.Rows[0]["S_MINGCHENG"].ToString();
        //        txtSheShuiDXDM.Text = dt_temp.Rows[0]["S_SHESHUIDXFLMC"].ToString();
        //        txtSheShuiDXMC.Text = dt_temp.Rows[0]["S_SHESHUIDXFLMC"].ToString();
        //        txtChaoBiaoRQ.Text = dt_temp.Rows[0]["D_CHAOBIAORQ"].ToString();
        //        txtBiaoFenL.Text = dt_temp.Rows[0]["S_BFL"].ToString();
        //        txtShuiBiaoHM2.Text = dt_temp.Rows[0]["S_SHUIBIAOHM"].ToString();
        //        txtChaoMa.Text = dt_temp.Rows[0]["I_BENYUECM"].ToString();
        //        txtYongShuiL.Text = dt_temp.Rows[0]["I_YONGSHUIL"].ToString();
        //        txtShuiBiaoDZ2.Text = dt_temp.Rows[0]["S_SHUIBIAODZ"].ToString();
        //        txtChaoBiaoZT.Text = dt_temp.Rows[0]["I_CHAOBIAOZT"].ToString();
        //        txtShuiSiZT.Text = dt_temp.Rows[0]["WORDSVALUE"].ToString();
        //        txtKouJing.Text = dt_temp.Rows[0]["I_KOUJING"].ToString();
        //        txtZongBiaoH.Text = dt_temp.Rows[0]["S_ZBH"].ToString();
        //        txtGuanWangKH2.Text = dt_temp.Rows[0]["S_KUAIHAO"].ToString();
        //        txtBiaoCeH.Text = dt_temp.Rows[0]["S_CH"].ToString();
        //        txtZhuangBiaoRQ.Text = dt_temp.Rows[0]["D_ZHUANGBIAORQ"].ToString();
        //        txtYongShuiJ.Text = dt_temp.Rows[0]["N_YSJ"].ToString();
               
        //    }
        //}
        /// <summary>
        /// 加载tab2页签数据
        /// </summary>
        private void LoadGridDataTab2(int h_index)
        {
            
            string sBm = cmbChaoBiaoBMtab2.Text;
            int index = Convert.ToInt32(cmbChaoBiaoBMtab2.Value);
            int i_y = Convert.ToInt32(cmbShuiLiangYtab2.Text);
            int i_m = Convert.ToInt32(cmbShuiLiangMtab2.Text);
            this.dtJinYiNSJTab2 = _SpHelper.P_YSCX_ZLSGSSJCX_JYNSJ(sBm, txtShuiBiaoBHSel.Text, index, i_y, i_m,1).Tables[0];
            if (this.dtJinYiNSJTab2 != null && this.dtJinYiNSJTab2.Rows.Count > 0)
            {
                txtYongHuHtab2.Text = this.dtJinYiNSJTab2.Rows[0]["S_YONGHUH"].ToString();
                txtKaoHeLXtab2.Text = this.dtJinYiNSJTab2.Rows[0]["KELX"].ToString();
                txtShuiBiaoHtab2.Text = this.dtJinYiNSJTab2.Rows[0]["S_SHUIBIAOBH"].ToString();
                txtShuiBiaoHMtab2.Text = this.dtJinYiNSJTab2.Rows[0]["S_SHUIBIAOHM"].ToString();
                txtXingZhengQtab2.Text = this.dtJinYiNSJTab2.Rows[0]["S_GUANLIKMC"].ToString();//this.dtJinYiNSJTab2.Rows[0]["XZQ"].ToString();
                txtShuiBiaoDZtab2.Text = this.dtJinYiNSJTab2.Rows[0]["S_SHUIBIAODZ"].ToString();
                txtDanJiatab2.Text = this.dtJinYiNSJTab2.Rows[0]["N_YSJ"].ToString();
                string gsgs=this.dtJinYiNSJTab2.Rows[0]["S_SUOSHUSF"].ToString();
                txtGongShuiGStab2.Text = gsgs.Length > 4 ? gsgs.Substring(0, 4) : gsgs;
                txtChaoBiaoBMtab2.Text = gsgs.Length > 4 ? gsgs.Substring(0, 4) : gsgs; // this.dtJinYiNSJTab2.Rows[0]["S_GUANLIKMC"].ToString();
                txtCeHaotab2.Text = this.dtJinYiNSJTab2.Rows[0]["S_SHUIBIAOCH"].ToString();
                txtSheShuiDXtab2.Text = this.dtJinYiNSJTab2.Rows[0]["SSDX"].ToString();
                txtKouJingtab2.Text = this.dtJinYiNSJTab2.Rows[0]["I_KOUJING"].ToString();
                txtBiaoFXtab2.Text = this.dtJinYiNSJTab2.Rows[0]["WORDSCONTENT"].ToString();
                txtZongBHtab2.Text = this.dtJinYiNSJTab2.Rows[0]["S_ZBH"].ToString();

                DataTable dt = _SpHelper.P_YSCX_ZLSGSSJCX_JYNSJ_SL(this.dtJinYiNSJTab2.Rows[0]["S_SHUIBIAOBH"].ToString(), i_y, i_m).Tables[0];
                if (dt.Rows.Count>0) 
                {
                    txtYiYuetab2.Text = dt.Rows[0]["SL1"].ToString();
                    txtErYuetab2.Text = dt.Rows[0]["SL2"].ToString();
                    txtSanYuetab2.Text = dt.Rows[0]["SL3"].ToString();
                    txtSiYuetab2.Text = dt.Rows[0]["SL4"].ToString();
                    txtWuYuetab2.Text = dt.Rows[0]["SL5"].ToString();
                    txtLiuYuetab2.Text = dt.Rows[0]["SL6"].ToString();
                    txtQiYuetab2.Text = dt.Rows[0]["SL7"].ToString();
                    txtBaYuetab2.Text = dt.Rows[0]["SL8"].ToString();
                    txtJiuYuetab2.Text = dt.Rows[0]["SL9"].ToString();
                    txtShiYuetab2.Text = dt.Rows[0]["SL10"].ToString();
                    txtShiYiYuetab2.Text = dt.Rows[0]["SL11"].ToString();
                    txtShiErYuetab2.Text = dt.Rows[0]["SL12"].ToString();
                    txtHeJitab2.Text = dt.Rows[0]["HEJI"].ToString();
                }
                
            }
            else 
            {
                txtYongHuHtab2.Text = txtKaoHeLXtab2.Text = txtShuiBiaoHtab2.Text = txtShuiBiaoHMtab2.Text = "";
                txtXingZhengQtab2.Text = txtShuiBiaoDZtab2.Text = txtDanJiatab2.Text = txtGongShuiGStab2.Text = "";
                txtChaoBiaoBMtab2.Text = txtCeHaotab2.Text = txtSheShuiDXtab2.Text = txtKouJingtab2.Text = "";
                txtBiaoFXtab2.Text = txtZongBHtab2.Text = "";

                txtYiYuetab2.Text = txtErYuetab2.Text = txtSanYuetab2.Text = txtSiYuetab2.Text = txtWuYuetab2.Text = txtLiuYuetab2.Text
                    = txtQiYuetab2.Text = txtBaYuetab2.Text = txtJiuYuetab2.Text = txtShiYuetab2.Text = txtShiYiYuetab2.Text
                    = txtShiErYuetab2.Text = "";
                txtHeJitab2.Text = "";
            }
           
            
        }

        /// <summary>
        /// 加载tab3数据
        /// </summary>
        private void LoadGridDataTab3()
        {
            string dept = cmbChaoBiaoBMtab3.Text;
            string area = cmbXingZhengQtab3.Value.ToString();
            int i_y = Convert.ToInt32(cmbShuiLiangYtab3.Text);
            string i_m =cmbShuiLiangMtab3.Text;
            this.dtShiKaoHSLFXtab3 = SearchSpHelper.P_YSCX_ZLSGSSJCX_SKHSLFX2(i_y, i_m, dept, area).Tables[0];
            gvKaoHeSLFXtab3.DataSource = this.dtShiKaoHSLFXtab3;
            gvKaoHeSLFXtab3.DataBind(); 
        }

        /// <summary>
        /// 加载tab4考核率
        /// </summary>
        private void LoadGridDataTab4() 
        {
            string v_y = cmbShuiLiangYtab4.Text;
            string v_m = cmbShuiLiangMtab4.Text;
            //加载第一个grid数据集
            this.dtShiKaoHSLFXtab4_1 = SearchSpHelper.P_YSCX_ZLSGSSJCX_KHL1(v_y, v_m).Tables[0];
            this.gvKaoHeSLFXtab4.DataSource= this.dtShiKaoHSLFXtab4_1;
            this.gvKaoHeSLFXtab4.DataBind();
            //加载第二个grid数据集
            this.dtShiKaoHSLFXtab4_2 = SearchSpHelper.P_YSCX_ZLSGSSJCX_KHL2(v_y, v_m).Tables[0];
            if (this.dtShiKaoHSLFXtab4_2.Rows[0][0].ToString() != "-1")
            {
                this.gvZiLaiSKHLtab4.DataSource = this.dtShiKaoHSLFXtab4_2;
                this.gvZiLaiSKHLtab4.DataBind();
            }
        }

        /// <summary>
        /// 加载tab5计划用水率
        /// </summary>
        private void LoadGridDataTab5()
        {
            int v_y =Convert.ToInt32( cmbShuiLiangYtab5.Text);
            int v_m =Convert.ToInt32( cmbShuiLiangMtab5.Text);
            //加载第一个grid数据集
            this.dtJiHuaYSLtab5_1 = SearchSpHelper.P_YSCX_ZLSGSSJCX_JHYSL1(v_y, v_m).Tables[0];
            this.gvJiHuaYSLtab5.DataSource = this.dtJiHuaYSLtab5_1;
            this.gvJiHuaYSLtab5.DataBind();
            //加载第二个grid数据集
            this.dtJiHuaYSLtab5_2 = SearchSpHelper.P_YSCX_ZLSGSSJCX_JHYSL2(v_y, v_m).Tables[0];
            this.gvKaoHeSLtab5.DataSource = this.dtJiHuaYSLtab5_2;
            this.gvKaoHeSLtab5.DataBind();
        }
        #endregion

        /// <summary>
        /// 计算
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnJiSuantab6_Click(object sender, EventArgs e)
        {
            string i_ym = txtShuiLiangYMtab6.Text;
            if (i_ym.Length == 6)
            {
                string i_y = i_ym.Substring(0, 4);
                string i_m = i_ym.Substring(4, 2);
                this.dtKaoHeSLtab6 = SearchSpHelper.P_YSCX_ZLSGSSJCX_KHSL_JS(i_y, i_m).Tables[0];
                gvKaoHeSLSRtab6.DataSource = this.dtKaoHeSLtab6;
                gvKaoHeSLSRtab6.DataBind();
            }
        }
        /// <summary>
        /// 最小水量年月
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void FirstTab6_Click(object sender, EventArgs e)
        {
            txtShuiLiangYMtab6.Text = this.min_ym.ToString();
            LoadDataTab6();
            FirstTab6.Enabled = false;
            LastTab6.Enabled = false;
            NextTab6.Enabled = true;
            FinalTab6.Enabled = true;
        }
        /// <summary>
        /// 上一个水量年月
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LastTab6_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(txtShuiLiangYMtab6.Text) > this.min_ym)
            {
                int ym_now = Convert.ToInt32(txtShuiLiangYMtab6.Text);
                int last = 0;
                if (ym_now % 100 == 1)
                {
                    last = Convert.ToInt32(txtShuiLiangYMtab6.Text) - 89;
                }
                else
                {
                    last = Convert.ToInt32(txtShuiLiangYMtab6.Text) - 1;
                }

                txtShuiLiangYMtab6.Text = last.ToString();
                LoadDataTab6();
                NextTab6.Enabled = true;
                FinalTab6.Enabled = true;
            }
            else
            {
                FirstTab6.Enabled = false;
                LastTab6.Enabled = false;
            }
        }
        /// <summary>
        /// 下一个水量年月
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void NextTab6_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(txtShuiLiangYMtab6.Text) < this.max_ym)
            {
                int ym_now = Convert.ToInt32(txtShuiLiangYMtab6.Text);
                int next = 0;
                if (ym_now % 100 == 12)
                {
                    next = Convert.ToInt32(txtShuiLiangYMtab6.Text) + 89;
                }
                else
                {
                    next = Convert.ToInt32(txtShuiLiangYMtab6.Text) + 1;
                }

                txtShuiLiangYMtab6.Text = next.ToString();
                LoadDataTab6();
                FirstTab6.Enabled = true;
                LastTab6.Enabled = true;
            }
            else
            {
                NextTab6.Enabled = false;
                FinalTab6.Enabled = false;
            }
        }
        /// <summary>
        /// 最大水量年月
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void FinalTab6_Click(object sender, EventArgs e)
        {
            txtShuiLiangYMtab6.Text = this.max_ym.ToString();
            LoadDataTab6();
            FirstTab6.Enabled = true;
            LastTab6.Enabled = true;
            NextTab6.Enabled = false;
            FinalTab6.Enabled = false;
        }

        /// <summary>
        /// 加载tab6页签显示框数据
        /// </summary>
        private void LoadDataTab6()
        {
            string ym = txtShuiLiangYMtab6.Text;
            if (ym.Length == 6)
            {
                string v_y = ym.Substring(0, 4);
                string v_m = ym.Substring(4, 2);
                DataTable dt = _YS_CX_KAOHESLBLL.SelectYS_CX_KAOHESLsDynamic(string.Format("I_Y='{0}' AND I_M='{1}'", v_y, v_m), null);
                if (dt != null && dt.Rows.Count > 0)
                {
                    txtShiShuZLS1.Text = dt.Rows[0]["I_SCity"].ToString();
                    txtShiShuZLS2.Text = dt.Rows[0]["I_SCity_g"].ToString();
                    txtShiShuZLS3.Text = dt.Rows[0]["I_ACITY"].ToString();
                    txtShiShuZLS4.Text = dt.Rows[0]["I_ACITY_G"].ToString();
                    txtJiaoQuSZLS1.Text = dt.Rows[0]["I_SSub"].ToString();
                    txtJiaoQuSZLS2.Text = dt.Rows[0]["I_SSub_g"].ToString();
                    txtJiaoQuSZLS3.Text = dt.Rows[0]["I_ASub"].ToString();
                    txtJiaoQuSZLS4.Text = dt.Rows[0]["I_ASub_g"].ToString();
                    txtDiBiaoS1.Text = dt.Rows[0]["I_SUp"].ToString();
                    txtDiBiaoS2.Text = dt.Rows[0]["I_SUp_g"].ToString();
                    txtDiBiaoS3.Text = dt.Rows[0]["I_AUp"].ToString();
                    txtDiBiaoS4.Text = dt.Rows[0]["I_AUp_g"].ToString();
                    txtDiXiaS1.Text = dt.Rows[0]["I_SUnder"].ToString();
                    txtDiXiaS2.Text = dt.Rows[0]["I_SUnder_g"].ToString();
                    txtDiXiaS3.Text = dt.Rows[0]["I_AUnder"].ToString();
                    txtDiXiaS4.Text = dt.Rows[0]["I_AUnder_g"].ToString();
                    txtDiXiaSSC1.Text = dt.Rows[0]["I_SUnderSC"].ToString();
                    txtDiXiaSSC2.Text = dt.Rows[0]["I_SUnderSC_g"].ToString();
                    txtDiXiaSSC3.Text = dt.Rows[0]["I_AUnderSC"].ToString();
                    txtDiXiaSSC4.Text = dt.Rows[0]["I_AUnderSC_g"].ToString();
                    txtShiShuZLStab6.Text = dt.Rows[0]["I_Ykhsl"].ToString();
                    this.KaoHeSLTab6_ID = Convert.ToInt32(dt.Rows[0]["ID"]);
                }
                else
                {
                    txtShiShuZLS1.Text = "";
                    txtShiShuZLS2.Text = "";
                    txtJiaoQuSZLS1.Text = "";
                    txtJiaoQuSZLS2.Text = "";
                    txtJiaoQuSZLS3.Text = "";
                    txtJiaoQuSZLS4.Text = "";
                    txtDiBiaoS1.Text = "";
                    txtDiBiaoS2.Text = "";
                    txtDiBiaoS3.Text = "";
                    txtDiBiaoS4.Text = "";
                    txtDiXiaS1.Text = "";
                    txtDiXiaS2.Text = "";
                    txtDiXiaS3.Text = "";
                    txtDiXiaS4.Text = "";
                    txtDiXiaSSC1.Text = "";
                    txtDiXiaSSC2.Text = "";
                    txtDiXiaSSC3.Text = "";
                    txtDiXiaSSC4.Text = "";
                    txtShiShuZLStab6.Text = "";
                }
            }
        }

        /// <summary>
        /// 隐藏按钮事件tab6
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnHid_Click(object sender, EventArgs e)
        {
            LoadDataTab6();
        }

        /// <summary>
        /// tab6数据保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSavetab6_Click(object sender, EventArgs e)
        {
            string ym = txtShuiLiangYMtab6.Text;
            if (ym.Length == 6)
            {
                string v_y = ym.Substring(0, 4);
                string v_m = ym.Substring(4, 2);
                DataTable dt = _YS_CX_KAOHESLBLL.SelectYS_CX_KAOHESLsDynamic(string.Format("I_Y='{0}' AND I_M='{1}'", v_y, v_m), null);
                if (dt != null && dt.Rows.Count > 0)
                {
                    _YS_CX_KAOHESL = _YS_CX_KAOHESLBLL.SelectYS_CX_KAOHESL(this.KaoHeSLTab6_ID);
                }
                else
                {
                    _YS_CX_KAOHESL.ID = 0;
                    _YS_CX_KAOHESL.I_M = v_m;
                    _YS_CX_KAOHESL.I_Y = v_y;
                }
                _YS_CX_KAOHESL.I_SCITY = Convert.ToDecimal(txtShiShuZLS1.Text != "" ? txtShiShuZLS1.Text : "0");
                _YS_CX_KAOHESL.I_SCITY_G = Convert.ToDecimal(txtShiShuZLS2.Text != "" ? txtShiShuZLS2.Text : "0");
                _YS_CX_KAOHESL.I_SSUB = Convert.ToDecimal(txtJiaoQuSZLS1.Text != "" ? txtJiaoQuSZLS1.Text : "0");
                _YS_CX_KAOHESL.I_SSUB_G = Convert.ToDecimal(txtJiaoQuSZLS2.Text != "" ? txtJiaoQuSZLS2.Text : "0");
                _YS_CX_KAOHESL.I_ASUB = Convert.ToDecimal(txtJiaoQuSZLS3.Text != "" ? txtJiaoQuSZLS3.Text : "0");
                _YS_CX_KAOHESL.I_ASUB_G = Convert.ToDecimal(txtJiaoQuSZLS4.Text != "" ? txtJiaoQuSZLS4.Text : "0");
                _YS_CX_KAOHESL.I_SUP = Convert.ToDecimal(txtDiBiaoS1.Text != "" ? txtDiBiaoS1.Text : "0");
                _YS_CX_KAOHESL.I_SUP_G = Convert.ToDecimal(txtDiBiaoS2.Text != "" ? txtDiBiaoS2.Text : "0");
                _YS_CX_KAOHESL.I_AUP = Convert.ToDecimal(txtDiBiaoS3.Text != "" ? txtDiBiaoS3.Text : "0");
                _YS_CX_KAOHESL.I_AUP_G = Convert.ToDecimal(txtDiBiaoS4.Text != "" ? txtDiBiaoS4.Text : "0");
                _YS_CX_KAOHESL.I_SUNDER = Convert.ToDecimal(txtDiXiaS1.Text != "" ? txtDiXiaS1.Text : "0");
                _YS_CX_KAOHESL.I_SUNDER_G = Convert.ToDecimal(txtDiXiaS2.Text != "" ? txtDiXiaS2.Text : "0");
                _YS_CX_KAOHESL.I_AUNDER = Convert.ToDecimal(txtDiXiaS3.Text != "" ? txtDiXiaS3.Text : "0");
                _YS_CX_KAOHESL.I_AUNDER_G = Convert.ToDecimal(txtDiXiaS4.Text != "" ? txtDiXiaS4.Text : "0");
                _YS_CX_KAOHESL.I_SUNDERSC = Convert.ToDecimal(txtDiXiaSSC1.Text != "" ? txtDiXiaSSC1.Text : "0");
                _YS_CX_KAOHESL.I_SUNDERSC_G = Convert.ToDecimal(txtDiXiaSSC2.Text != "" ? txtDiXiaSSC2.Text : "0");
                _YS_CX_KAOHESL.I_AUNDERSC = Convert.ToDecimal(txtDiXiaSSC3.Text != "" ? txtDiXiaSSC3.Text : "0");
                _YS_CX_KAOHESL.I_AUNDERSC_G = Convert.ToDecimal(txtDiXiaSSC4.Text != "" ? txtDiXiaSSC4.Text : "0");
                _YS_CX_KAOHESL.I_YKHSL = Convert.ToDecimal(txtShiShuZLStab6.Text != "" ? txtShiShuZLStab6.Text : "0");
                bool success = _YS_CX_KAOHESLBLL.InsertOrUpdate(_YS_CX_KAOHESL, null);
                if (success)
                {
                    LoadDataTab6();
                    int iYm = Convert.ToInt32(ym);
                    if (max_ym < iYm) max_ym = iYm;
                    PageTools.AlertMsg(this, "保存成功！");
                }
            }
        }

        /// <summary>
        /// tab6放弃保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnGiveUptab6_Click(object sender, EventArgs e)
        {
            LoadDataTab6();
        }

        /// <summary>
        /// 前台表格行改变事件回调方法
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            object id = this.hdCollection.Get("S_SHUIBIAOBH");
            string msg = "";
            if (e.Parameter == "setinfo")
            {

                DataTable dt_temp = _SpHelper.P_YSCX_ZLSGSSJCX_YCBCX("全部", "全部","全部", Convert.ToInt32(cmbShuiLiangYtab1.Text), Convert.ToInt32(cmbShuiLiangMtab1.Text), "全部", 1, id.ToString(), "").Tables[0];
                if (dt_temp != null && dt_temp.Rows.Count > 0)
                {
                    msg = string.Join("|", Convert.ToString(dt_temp.Rows[0]["S_SHUIBIAOBH"]), Convert.ToString(dt_temp.Rows[0]["S_MINGCHENG"]),
                        Convert.ToString(dt_temp.Rows[0]["S_SHESHUIDXFLDM"]), Convert.ToString(dt_temp.Rows[0]["S_SHESHUIDXFLMC"]), Convert.ToString(dt_temp.Rows[0]["D_CHAOBIAORQ"]),
                        Convert.ToString(dt_temp.Rows[0]["I_TYPE"]), Convert.ToString(dt_temp.Rows[0]["S_SHUIBIAOHM"]), Convert.ToString(dt_temp.Rows[0]["I_BENYUECM"]),
                        Convert.ToString(dt_temp.Rows[0]["I_YONGSHUIL"]), Convert.ToString(dt_temp.Rows[0]["S_SHUIBIAODZ"]), Convert.ToString(dt_temp.Rows[0]["CHAOBIAOZT"]),
                        "", Convert.ToString(dt_temp.Rows[0]["I_KOUJING"]), Convert.ToString(dt_temp.Rows[0]["S_ZBH"]),
                        Convert.ToString(dt_temp.Rows[0]["S_KUAIHAO"]), Convert.ToString(dt_temp.Rows[0]["S_CH"]), Convert.ToString(dt_temp.Rows[0]["D_ZHUANGBIAORQ"]),
                        Convert.ToString(dt_temp.Rows[0]["N_YSJ"]), Convert.ToString(dt_temp.Rows[0]["S_YUANCHAOBZT"]));
                }

            }
            else if (e.Parameter == "jynsj")
            {
                string sBm = cmbChaoBiaoBMtab2.Text;
                int index = Convert.ToInt32(cmbChaoBiaoBMtab2.Value);
                int i_y = Convert.ToInt32(cmbShuiLiangYtab2.Text);
                int i_m = Convert.ToInt32(cmbShuiLiangMtab2.Text);
                int count = 0;
                DataTable dt_temp_tab2 = new DataTable();
                if (Convert.ToInt32(id) == -1)
                {
                    count = Convert.ToInt32(_SpHelper.P_YSCX_ZLSGSSJCX_JYNSJ(sBm, txtShuiBiaoBHSel.Text, index, i_y, i_m, Convert.ToInt32(id)).Tables[0].Rows[0][0]);
                }
                if (count != 0)
                {
                    dt_temp_tab2 = _SpHelper.P_YSCX_ZLSGSSJCX_JYNSJ(sBm, txtShuiBiaoBHSel.Text, index, i_y, i_m, count).Tables[0];
                }
                else
                {
                    dt_temp_tab2 = _SpHelper.P_YSCX_ZLSGSSJCX_JYNSJ(sBm, txtShuiBiaoBHSel.Text, index, i_y, i_m, Convert.ToInt32(id)).Tables[0];
                }
                if (dt_temp_tab2 != null && dt_temp_tab2.Rows.Count > 0)
                {
                    string gsgs = dt_temp_tab2.Rows[0]["S_SUOSHUSF"].ToString().Length > 4 ? dt_temp_tab2.Rows[0]["S_SUOSHUSF"].ToString().Substring(0, 4) : dt_temp_tab2.Rows[0]["S_SUOSHUSF"].ToString();
                    DataTable dtSL = _SpHelper.P_YSCX_ZLSGSSJCX_JYNSJ_SL(dt_temp_tab2.Rows[0]["S_SHUIBIAOBH"].ToString(), i_y, i_m).Tables[0];
                    msg = string.Join("|", Convert.ToString(dt_temp_tab2.Rows[0]["S_YONGHUH"]), Convert.ToString(dt_temp_tab2.Rows[0]["KELX"]),
                        Convert.ToString(dt_temp_tab2.Rows[0]["S_SHUIBIAOBH"]),
                         Convert.ToString(dt_temp_tab2.Rows[0]["S_SHUIBIAOHM"]), Convert.ToString(dt_temp_tab2.Rows[0]["S_GUANLIKMC"]), Convert.ToString(dt_temp_tab2.Rows[0]["S_SHUIBIAODZ"]),
                         Convert.ToString(dt_temp_tab2.Rows[0]["N_YSJ"]), gsgs.ToString(), Convert.ToString(dt_temp_tab2.Rows[0]["S_SHUIBIAOCH"]),
                         Convert.ToString(dt_temp_tab2.Rows[0]["SSDX"]), Convert.ToString(dt_temp_tab2.Rows[0]["I_KOUJING"]), Convert.ToString(dt_temp_tab2.Rows[0]["WORDSCONTENT"]),
                         Convert.ToString(dt_temp_tab2.Rows[0]["S_ZBH"]), count, gsgs.ToString(),
                         dtSL.Rows[0]["SL1"].ToString(),dtSL.Rows[0]["SL2"].ToString(),dtSL.Rows[0]["SL3"].ToString(),dtSL.Rows[0]["SL4"].ToString(),dtSL.Rows[0]["SL5"].ToString(),
                         dtSL.Rows[0]["SL6"].ToString(),dtSL.Rows[0]["SL7"].ToString(),dtSL.Rows[0]["SL8"].ToString(),dtSL.Rows[0]["SL9"].ToString(),dtSL.Rows[0]["SL10"].ToString(),
                         dtSL.Rows[0]["SL11"].ToString(), dtSL.Rows[0]["SL12"].ToString(), dtSL.Rows[0]["HEJI"].ToString());
                }
            }
            e.Result = e.Parameter + "|0|" + msg;
        }

        protected void btnExport_Click(object sender, EventArgs e)
        {
            int index = ASPxPageControl1.ActiveTabIndex;
            string sName = "";
            if (index == 0)
            {
                gvYueChaoBQKTab1.DataSource = this.dtYueChaoBQKTab1;
                gvYueChaoBQKTab1.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvYueChaoBQKTab1";
                sName = "月抄表情况";
                gvYueChaoBQKTab1.Settings.ShowFooter = false;
            }
            else if (index == 2)
            {
                gvKaoHeSLFXtab3.DataSource = this.dtShiKaoHSLFXtab3;
                gvKaoHeSLFXtab3.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvKaoHeSLFXtab3";
                sName = "实考核水量分析";
                gvKaoHeSLFXtab3.Settings.ShowFooter = false;
            }
            
            ASPxGridViewExporter1.WriteXlsToResponse(sName);
        }

    }
}